#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
#include <signal.h>

/*
^CI catch the SIGINT
^C
 */

typedef void (*sighandler_t)(int);

sighandler_t oldact;

void handler(int sig){
	printf("I catch the SIGINT\n");
	//将CRTL + C终止信号的行为还原成杀掉进程 
	signal(SIGINT, oldact);
}

int main(){
	//自定义CTRL + C 终止信号的行为，原先是杀掉进程，现在是打印一行话
	oldact = signal(SIGINT, handler);

	while(1){
		sleep(1);
	}
}
